package com.bj58.ecdata.dashboard.utils;

import java.util.List;

import org.apache.commons.lang.StringUtils;

public class DJsonUtils {

	public static final String NULLObject = "{}";
	public static final String NULLArray = "[]";

	/**
	 * 
	 * @param list
	 * @return
	 * @author guolu 2015-1-24
	 */
	public static String getJsonArrayByList(List<String> list) {
		if (list == null || list.isEmpty()) {
			return "[]";
		}
		StringBuilder sb = new StringBuilder("[");
		for (int i = 0, loop = list.size(); i < loop; i++) {
			sb.append("'");
			sb.append(list.get(i));
			sb.append("'");
			sb.append(",");
		}
		return StringUtils.removeEnd(sb.toString(), ",") + "]";
	}
}
